/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FolderChunks;

import java.util.ArrayList;

/**
 *
 * @author DongVan
 */
public class FilenameChunk {
    private String m_Filename;
    private ArrayList<InfoChunk> m_ListChunk ;

    public String getM_Filename() {
        return m_Filename;
    }

    public void setM_Filename(String m_Filename) {
        this.m_Filename = m_Filename;
    }

    public ArrayList<InfoChunk> getM_ListChunk() {
        return m_ListChunk;
    }

    public void setM_ListChunk(ArrayList<InfoChunk> m_ListChunk) {
        this.m_ListChunk = m_ListChunk;
    }
    
    public FilenameChunk(){
        this.m_Filename = "";
        this.m_ListChunk = new ArrayList<>();
    }
    
    public FilenameChunk(FilenameChunk param_filename_chunk){
        this.m_Filename = param_filename_chunk.getM_Filename();
        this.m_ListChunk = new ArrayList<>(param_filename_chunk.getM_ListChunk());
    }
    
    public FilenameChunk(String fileName, ArrayList listChunk){
        this.m_Filename = fileName;
        this.m_ListChunk = listChunk;
    }
    
    public FilenameChunk(ArrayList<String> param_chunks){
        this.m_Filename = "";
        if(!param_chunks.isEmpty()){
           for(String item : param_chunks){
               InfoChunk infoChunk = new InfoChunk(item); 
               if(this.m_Filename.equals("")){
                   this.m_Filename = infoChunk.getM_FileName();
               }
               this.m_ListChunk.add(infoChunk); 
           } 
        }
    }
    
    public String getFolderNameContainChunks(){
        if (getM_Filename().contains(".")) {
            String[] arrayFolderName = getM_Filename().split(".");
            if(arrayFolderName.length >= 2){
                return arrayFolderName[0];
            }
        }
        return getM_Filename();
    }
    
    public String getExtensionFile(){
        if (getM_Filename().contains(".")) {
            String[] arrayFolderName = getM_Filename().split(".");
            if(arrayFolderName.length >= 2){
                return arrayFolderName[1];
            }
        }
        return getM_Filename();
    }
    
    public void removeItem(InfoChunk item){
        if(this.getM_ListChunk().contains(item)){
            this.getM_ListChunk().remove(item); 
        }
    }
    
    public boolean isEmpty(){
        return this.getM_ListChunk().isEmpty();
    }
}
